package com.biboheart.adapter.express.support;

import com.biboheart.adapter.express.actuator.GenericActuator;
import com.biboheart.adapter.support.enums.ValueTypeEnum;
import com.biboheart.adapter.support.utils.ObjectTypeUtils;

final class ConvertActuator implements GenericActuator {
    @Override
    public Object execute(Object source, Object... args) {
        if (args.length == 0) {
            return source;
        }
        String valueType = ObjectTypeUtils.convertType(args[0], String.class);
        ValueTypeEnum valueTypeEnum = ValueTypeEnum.getValueType(valueType);
        if (null == valueTypeEnum) {
            return source;
        }
        return ObjectTypeUtils.convertType(source, valueTypeEnum.desc());
    }
}
